/******************************************************************************
 cnome: A C++ source "genes" discover. :-)

 See more details at:

   http://www.codeplex.com/cnome

 The original author site is at: http://www.alexandre-barbosa.com/

 Copyright (c) 2008 Alexandre Barbosa.
 Distributed under the MIT License. (See accompanying file LICENSE-MIT.txt 
 or at http://www.codeplex.com/cnome/license)
 ******************************************************************************/

#ifndef SCOPES_H
#define SCOPES_H

#include <string>

#include "cnome_typedefs.h"
    
namespace cnome { namespace scopes {
class scopesFromStr
{
public:
	scopesFromStr(const std::string& v, size_t suffixSize = std::string::npos);
	const std::string& current_scope()const;
	const std::string& next_scope();

private:
	bool m_first_time;
	size_t m_idx;
	const std::string& m_value;
	std::string m_scope;
	std::size_t m_suffixSize;
	lstItSblsT::const_iterator m_idxLstItSbls;

	void advance_idx();
	std::size_t find_right_parenthesis(std::size_t leftParentIdx);
};

class scopesFromScp
{
public:
	scopesFromScp(const symbolItemPtr& v, size_t suffixSize = std::string::npos );
	const std::string& currentScope()const;
	const std::string& nextScope();

private:
	std::size_t m_suffixSize;
	const symbolItemPtr m_sbl;
	std::string m_value;
};

void enter_scope(std::string& val, cnome_iterator& first);
std::string& get_scope(std::string& scp, const char* tk=0);
std::string& get_previous_scope(std::string& scp);
const itSymbolItem get_symbol_scope(const char* scp);
std::string& get_scope(std::string& scp, scopeT& tk, bool useCurScope = true);
std::string& get_scope(std::string& scp, scopeT& tk, size_t& suffixSize, bool useCurScope = true);
}} // namespace cnome { namespace scopes {

#endif // SCOPES_H
